// pages/My/info.js
const Controllers = require('../controllers/Controller.js').controller;
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    lists: [
      {
        laber: '所属服务商：',
        key: 'agentName'
      },
      {
        laber: '姓名：',
        key: 'name'
      },
      {
        laber: '联系电话：',
        key: 'mobile'
      },
      {
        laber: '入驻时间：',
        key: 'createTime'
      }
    ],
    userInfo: {}
  },

  staffDetail() {
    var that = this;
    var agentStaffId = that.data.agentStaffId;
    Controllers.staffDetail({agentStaffId}).then(res => {
      console.log('staffDetail--res==', res);
      const { code, data, desc } = res;
      var now = new Date();
      const Y = now.getFullYear();
      const M = now.getMonth() + 1 > 9 ? now.getMonth() + 1 : '0' + now.getMonth() + 1;
      var toMonth = { ...data.toMonth, createTime: `${Y}-${M}`};

      that.setData({
        statistics: that.data.statistics,
        details: data,
        toMonth,
        list: data.commissionList
      })
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    that.setData({
      agentStaffId: options.id || ''
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this;
    // that.staffDetail();
    const staffIndex = wx.getStorageSync('staffIndex');
    console.log('staffIndex==', staffIndex);
    that.setData({
      staffIndex
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})